class Node{
    public int val;
    public Node next;
    public Node(int val){
        this.val=val;
    }
    public int getVal() {
        return val;
    }

    public void setVal(int val) {
        this.val = val;
    }

    public Node getNext() {
        return next;
    }

    public void setNext(Node next) {
        this.next = next;
    }
}
public class MyQueue {
    public Node fast;
    public Node right;
    public void offer(int val){
        Node cur=new Node(val);
        if(this.fast==null&&this.right==null){
            this.fast=cur;
            this.right=cur;
            return;
        }
        this.right.setNext(cur);
        this.right=cur;
    }
    public int poll(){
        if(this.fast==null){
            return -1;
        }
        else if(this.fast.next==null){
            int tmp=this.fast.getVal();
            this.fast=null;
            return tmp;
        }
        int tmp=this.fast.getVal();
        this.fast=this.fast.getNext();
        return tmp;
    }
    public int peek(){
        if(this.fast==null){
            return -1;
        }else{
            return this.fast.getVal();
        }
    }
}
